package com.cao.meet.vocie;

import android.annotation.SuppressLint;
import android.content.Context;
import android.media.AudioManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.blankj.utilcode.util.LogUtils;
import com.cao.meet.R;

public class VoiceActivity extends AppCompatActivity {

    private TextView voice_text;
    private AudioManager mAudioManager;
    private AdjustmentVoiceUtil voiceUtil;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_voice);
        mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        voice_text = (TextView) findViewById(R.id.voice_text);
        final Button down_voice = (Button) findViewById(R.id.down_voice);
        down_voice.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                down_voice();
            }
        });
        final Button up_voice = (Button) findViewById(R.id.up_voice);
        up_voice.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                up_voice();
            }
        });
        voiceUtil = AdjustmentVoiceUtil.getVoiceUtil().init(getApplicationContext());
    }

    private int voice_value = 0;

    @SuppressLint("SetTextI18n")
    private void up_voice() {
        if (voice_value < 100) {
            LogUtils.e("caolei", "张云强---up_voice");
            voice_value = voice_value + 2;
            voiceUtil.change_voice(AudioManager.STREAM_MUSIC, voice_value);
            LogUtils.e(voiceUtil.get_voice(AudioManager.STREAM_MUSIC));
        }
    }

    @SuppressLint("SetTextI18n")
    private void down_voice() {
        if (voice_value > 0) {
            voice_value = voice_value - 2;
            voiceUtil.change_voice(AudioManager.STREAM_MUSIC, voice_value);
            LogUtils.e(voiceUtil.get_voice(AudioManager.STREAM_MUSIC));
        }
    }
}
